/**
 * @file BleProtocol.h
 * @brief 
 * @author xuesong (wenshaoliu@foxmail.com)
 * @version 1.0
 * @date 2024-11-05
 * 
 * @copyright Copyright (c) 2024  by xuesong
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-11-05     <td>1.0     <td>xuesong   <td>内容
 * </table>
 */
#ifndef __BLE_PROTOCOL__H__
#define __BLE_PROTOCOL__H__

#ifdef __cplusplus
extern "C"
{
#endif

#include "types.h"

#define BLE_APP_CMD_HEAD    0xFA

typedef enum
{
	BLE_APP_CMD_WEIGHT = 1,	   // 重量值
	BLE_APP_CMD_TARE,	       // 去皮  
	BLE_APP_CMD_UNIT,	       //切换单位  
	BLE_APP_CMD_SLEEP,	       //休眠  
	BLE_APP_CMD_BATTERY,       //电池电量  
	BLE_APP_CMD_CONNECT,       //蓝牙连接  
	BLE_APP_CMD_TIME,          //time on  
	BLE_APP_CMD_START_TIME,    //time Start  
	BLE_APP_CMD_STOP_TIME,     //time Stop  
	BLE_APP_CMD_CLR_TIME,      //Clr time  
	BLE_APP_CMD_SPEED,         //Water Speed  
}BLE_APP_CMD;

typedef enum
{
	BLE_APP_CMD_MASK = 0x80,    // ble send 2 app mask with 0x80
}DIRECTION_MASK;

#pragma pack (1)
#define BLE_STRUCT_DATA_LEN    32
typedef struct
{
	uint8_t	 head;
    uint8_t  cmd;
	uint8_t  len;
	uint8_t  data[BLE_STRUCT_DATA_LEN];
}BleAppCmdData_t;
#pragma pack ()


uint8_t Pack2BleNotify(uint8_t cmd,uint8_t *data,uint16_t len);
void ProcessAppCmd(uint8_t *data,uint16_t len);
uint8_t PackTare2App(void);
uint8_t PackWeight2App(int32_t weight);
uint8_t PackTime2App(uint16_t time_second);

#ifdef __cplusplus
}
#endif

#endif


